package com.zyh.server.exception;

import com.zyh.server.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author: zyh
 * @Date: 2024-11-14-10:26
 * @Description
 */
@Slf4j
@ControllerAdvice
@ResponseBody
public class GlobalExceptionHandler {
	@ExceptionHandler(value = Exception.class)
	public R globalException(Exception e){
		log.error("全局异常捕获:{}",e);
		return R.fail("服务器异常，原因："+e.getMessage());
	}
}
